//
//  SearchTextField.m
//  AddressBook
//
//  Created by admin on 2017/5/22.
//  Copyright © 2017年 LaiCunBa. All rights reserved.
//

#import "LLSearchTextField.h"

@interface LLSearchTextField ()


@end

@implementation LLSearchTextField

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.returnKeyType = UIReturnKeySearch; // return 改为 搜索
        self.enablesReturnKeyAutomatically = YES; //这里设置为无文字就灰色不可点
        self.layer.cornerRadius = frame.size.height * 0.5;
        
        self.font = [UIFont systemFontOfSize:14];
        self.textColor = UIColorFromRGB(333333);

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 15, frame.size.height)];
        imageView.image = [UIImage imageNamed:@"good_list_search"];
        self.leftView = imageView;
        self.leftView.contentMode = UIViewContentModeScaleAspectFit;
        self.leftViewMode = UITextFieldViewModeAlways;
        
        self.clearButtonMode = UITextFieldViewModeAlways;
        
        
    }
    return self;
}

// leftview位置
- (CGRect)leftViewRectForBounds:(CGRect)bounds
{
    CGRect rect = [super leftViewRectForBounds:bounds];
    
    rect.origin.x += 10;
    
    return rect;
    
}


// 文字位置
- (CGRect)textRectForBounds:(CGRect)bounds
{
    CGRect rect = [super editingRectForBounds:bounds];

    rect.origin.x += 5;

    return rect;
}

- (CGRect)editingRectForBounds:(CGRect)bounds
{
    CGRect rect = [super editingRectForBounds:bounds];

    rect.origin.x += 5;

    return rect;
}


@end
